import { IsString, IsNumber, IsBoolean, IsDate, IsOptional, IsEnum, IsArray } from 'class-validator';
import { ApiProperty, OmitType, IntersectionType } from '@nestjs/swagger';
import { PagingDto } from 'src/common/dto/index';
import { CharEnum } from 'src/common/enum/index';
import { Type } from 'class-transformer';

export class BaseSpectrumDto {
  @ApiProperty({ required: false, description: 'id' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  id?: number;

  @ApiProperty({ required: false, description: '孩子ID' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  childId?: number;

  @ApiProperty({ required: false, description: '情绪流露维度数值' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  emotionFlow?: number;

  @ApiProperty({ required: false, description: '自我表达维度数值' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  selfExpression?: number;

  @ApiProperty({ required: false, description: '行为归因维度数值' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  behaviorAttribution?: number;

  @ApiProperty({ required: false, description: '困境应对维度数值' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  difficultyCoping?: number;

  @ApiProperty({ required: false, description: '互动主动维度数值' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  interactionInitiative?: number;

  @ApiProperty({ required: false, description: 'report_tags' })
  @IsOptional()
  @IsString()
  reportTags?: string;

  @ApiProperty({ required: false, description: 'report_content' })
  @IsOptional()
  @IsString()
  reportContent?: string;

  @ApiProperty({ enum: CharEnum, required: false, description: '删除标志' })
  @IsOptional()
  @IsString()
  delFlag?: string;

  @ApiProperty({ required: false, description: '开始时间' })
  startTime?: string;

  @ApiProperty({ required: false, description: '结束时间' })
  endTime?: string;

  @ApiProperty({ required: false, description: '创建时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  createTime?: Array<string>;

  @ApiProperty({ required: false, description: '更新时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  updateTime?: Array<string>;
}

export class CreateSpectrumDto extends OmitType(BaseSpectrumDto, ['id', 'delFlag', 'createTime']) {}

export class UpdateSpectrumDto extends OmitType(BaseSpectrumDto, ['delFlag', 'createTime']) {}

// 修改QuerySpectrumDto类以明确包含childId和pageNum参数
export class QuerySpectrumDto extends IntersectionType(BaseSpectrumDto, PagingDto) {}

// 查询信息
export class QueryInfoSpectrumDto {
  @ApiProperty({ required: false, description: '孩子ID' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  childId?: number;

  @ApiProperty({ required: false, description: '当前页码' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  currentPage?: number;
}

export class ListSpectrumDto extends OmitType(BaseSpectrumDto, ['delFlag', 'createTime', 'updateTime']) {}
